﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Zove.Numerics.Core;
using FunctionalCLR.Core;

namespace Zove.Desktop {
    public class ProgrammingEditor : EditingForm {

        public override string GetFileExtension() {
            return ".fpz";
        }

        public ProgrammingEditor()
            : base() {
        }

        public ProgrammingEditor(string fileName)
            : base(fileName) {
        }

        public override void Execute() {
            ConsoleWindow output = new ConsoleWindow();

            output.MdiParent = this.MdiParent;
            output.Show();

            ZoveNumericsInterpreter intp 
                = new ZoveNumericsInterpreter();
            try {
                intp.Execute(
                    base.GetTextEditorControl().Text, 
                    new string[] { });
            } catch (Exception ex) {
                MessageBox.Show(
                    string.Format(
                    "An error occured, check log file for details.\n{0}", ex.Message));
                DefaultDependencyManager.Instance.Logger.WriteLog(ex);
            }

            Console.WriteLine("Evaluation completed.");
        }

        public override string GetColouringScheme() {
            return "C#";
        }

        private void InitializeComponent() {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ProgrammingEditor));
            this.SuspendLayout();
            // 
            // ProgrammingEditor
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.ClientSize = new System.Drawing.Size(292, 273);
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Name = "ProgrammingEditor";
            this.ResumeLayout(false);
            this.PerformLayout();

        }
    }
}
